﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Utils.SoftReferences;
using GameObjects;

namespace WindowsGame.Ui
{
    class UiPoint : VisibleObject
    {
        public UiHex UiHex { get; set; }
        public SoftRef<Structure> Structure { get; set; }

        public UiPoint(UiModel uiModel)
            : base(uiModel)
        {
            uiModel.UiPoints.Add(this);
        }

        //public override float Alpha
        //{
        //    get
        //    {
        //        if (UiModel.UnitSelection != null && UiModel.UnitSelection.UiUnit != this)
        //            return .5f;
        //        else
        //            return 1f;
        //    }
        //}

        public override Vector3 DiffuseColor
        {
            get
            {
                return ColourHelper.FromHexString(Structure.Target.Color);
            }
        }

        public override void Update(GameTime gameTime)
        {
            //var pointX = 0f;
            //var pointY = 0f;
            //var numberOfUnits = UiHex.Hex.Target.Units.Count();
            //if (numberOfUnits > 1)
            //{
            //    var pointRatio = (float)unitNumber / (UiHex.Hex.Target.StackLimit * 2);
            //    if (numberOfUnits > UiHex.Hex.Target.StackLimit * 2)
            //        pointRatio = (float)unitNumber / numberOfUnits;
            //    var xStep = Math.Cos(pointRatio * 2 * Math.PI);
            //    var yStep = Math.Sin(pointRatio * 2 * Math.PI);
            //    pointX = (float)xStep * .6f;
            //    pointY = (float)yStep * .6f;
            //}

            WorldTransform = Matrix.CreateTranslation(0, 0, 0.3f) * UiHex.GetWorldTransform();

            base.Update(gameTime);
        }
    }
}